package org.jeecg.modules.flowable.controller.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.List;

/**
 * Title:  <br>
 * Desc:  <br>
 * Date: 6/8/22 5:00 PM <br>
 * Company: 联通（辽宁）产业互联网有限公司 <br>
 *
 * @author zxd
 * @version 1.0.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "PageResult对象", description = "")
public class PageResult<T> {

    @ApiModelProperty(value = "分页数据")
    private List<T> records;

    @ApiModelProperty(value = "总行数")
    private Long total;

    @ApiModelProperty(value = "每页数")
    private Integer size;

    @ApiModelProperty(value = "当前页数")
    private Integer current;

    @ApiModelProperty(value = "总页数")
    private Integer page;

    public Integer getPage() {
        int i = new BigDecimal(total).divide(new BigDecimal(size)).intValue();
        if (total % size > 0) {
            i = i + 1;
        }
        return i;
    }
}